Component({
  properties: {
    // 是否显示隐私弹窗
    show: {
      type: Boolean,
      value: false
    }
  },

  data: {
    showPrivacy: false,
    privacyContractName: ''
  },

  methods: {
    // 检查隐私授权状态
    checkPrivacyAuth() {
      return new Promise((resolve) => {
        if (wx.getPrivacySetting) {
          wx.getPrivacySetting({
            success: (res) => {
              this.setData({
                privacyContractName: res.privacyContractName,
                showPrivacy: true
              });
              
              resolve(!res.needAuthorization);
            },
            fail: () => {
              resolve(true);
            }
          });
        } else {
          resolve(true);
        }
      });
    },

    // 打开隐私协议
    openPrivacyContract() {
      wx.openPrivacyContract({
        success: () => {},
        fail: (err) => {
          console.error('打开隐私协议失败', err);
        }
      });
    },

    // 用户同意隐私协议
    handleAgree() {
      this.setData({ showPrivacy: false });
      this.triggerEvent('agree');
    },

    // 用户不同意隐私协议
    handleDisagree() {
      wx.showToast({
        title: '需要同意隐私政策才能继续使用',
        icon: 'none'
      });
    },

   
  }
});